<?php
namespace Api\Controller;
use Common\Controller\AppframeController;
class GuestbookController extends AppframeController{
	
	protected $guestbook_model;
	
	function _initialize() {
		parent::_initialize();
		$this->guestbook_model=D("Common/Guestbook");
	}
	
	function index(){
		
	}
	
	function addmsg(){
		if(!sp_check_verify_code()){
			//$this->error("验证码错误！");
			$data=4;
			$this->ajaxReturn($data);
			die;
		}
		
		if (IS_POST) {
			$uid=I('uid');
			if($uid){
				if ($this->guestbook_model->create()) {
					$result=$this->guestbook_model->add();
					if ($result!==false) {
						//$this->success("留言成功！");
						$data=1;
					} else {
						//$this->error("留言失败！");
						$data=0;
					}
				} else {
					//$this->error($this->guestbook_model->getError());
					$data=2;
				}
			}else{
				$data=3;
			}
			$this->ajaxReturn($data);
			$this->guestbook_model->close();
		}
		
	}
}